package com.jala.base;

import com.jala.base.data.WxSessionCache;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class WxSessionCacheManager implements ApplicationContextAware {
	
	private static ApplicationContext applicationContext;
	private static WxSessionCacheManager instance;

	private WxSessionCache wxSessionCache;

    public void setWxSessionCache(WxSessionCache wxSessionCache) {
		this.wxSessionCache = wxSessionCache;
	}

	public static WxSessionCache getWxSessionCache() {
    	if(instance != null){    	
    		return instance.wxSessionCache;
    	}else{    		
    		instance = applicationContext.getBean(WxSessionCacheManager.class);
    	}
        return instance.wxSessionCache;
    }
    
	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		WxSessionCacheManager.applicationContext = applicationContext;
	}		
	public static ApplicationContext getApplicationContext(){
		return applicationContext;
	}
}
